<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>添加角色</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="./css/w_main.css">
    <!--[if lt IE 9]>
      <script src="./lib/ie9/html5.min.js"></script>
      <script src="./lib/ie9/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="x-body">
        <div class="layui-row">
            <form class="senFormW" action="">
                <!--  <div class="layui-form-item">
                 <label for="L_id" class="layui-form-label">
                     <span class="x-red">*</span>
                     序号
                 </label>
                 <div class="layui-input-inline">
                     <input type="text" id="L_id" name="mbmc" required="" lay-verify="mbmc"
                     autocomplete="off" class="layui-input" readonly>
                 </div>
                 <div class="layui-form-mid layui-word-aux">
                     <span class="x-red">*</span>序号不可以修改
                 </div>
             </div> -->
                <div class="layui-form-item">
                    <label for="L_comName" class="layui-form-label">
                        <span class="x-red">*</span>
                        角色名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_comName" name="mbmc" required="" lay-verify="mbmc" autocomplete="off"
                            class="layui-input">
                        <!-- <select id="L_comName">
                         <option>请选择</option>
                     </select> -->
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_zdName" class="layui-form-label">
                        <span class="x-red">*</span>
                        菜单权限
                    </label>
                    <div class="layui-input-inline">
                        <div id="treeW"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-inline">
                        <a href="javascript:;" class="layui-btn" style="margin-left:60px;" id="editBtn">新增</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script type="text/javascript" src="./js/config.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript">
        var hideMenu = [];
        var wData = {};
        var url = app.url + 'dangan.json';

        layui.use(['table', 'laydate', 'tree'], function () {
            $ = layui.jquery;
            var laydate = layui.laydate;
            var table = layui.table;
            var tree = layui.tree;  //树形菜单


            /**树形菜单  文档  https://www.layui.com/doc/modules/tree.html ****/
            var inst1 = tree.render({
                elem: '#treeW', //绑定元素
                showCheckbox: true,
                data: [{
                    id : 1 ,
                    title: '任务管理',//一级菜单
                    children: [
                        {
                            id: '1_1',
                            title: '一张图指挥',//二级菜单
                            children: [{
                                id : '1_1_1' ,
                                title: '三级菜单' //三级菜单
                                //…… //以此类推，可无限层级
                            }
                            ]
                        },
                        {
                            id: '1_2',
                            title: '设备数据监控' //二级菜单
                        },
                        {
                            id: '1_3',
                            title: '报警险情管理' //二级菜单
                        },
                        {
                            id : '1_4' ,
                            title: '报警历史记录管理' //二级菜单
                        },
                        {
                            id : '1_5' ,
                            title: '待整改单位' //二级菜单
                        }
                    ]
                }, {
                    id : 2 ,
                    title: '陕西' //一级菜单
                    , children: [{
                        id : '2_1',
                        title: '西安' //二级菜单
                    }]
                }],
                oncheck: function (obj) { //点击复选框时触发
                    console.log('obj', obj);
                },
                click: function (obj) { // 在节点被点击后触发
                    console.log('obj', obj);
                },
                operate: function (obj) {//添加删除了才会触发这个回调
                    console.log('operate', obj);
                }
            });



            /***************修改提交 ****************/
            $('#editBtn').click(function () {
                var L_comName = $('#L_comName').val();
                var L_gzhong = $('#L_gzhong').val();
                var L_xiren = $('#L_xiren').val();
                var L_zdName = $('#L_zdName').val();
                var L_xirenPhone = $('#L_xirenPhone').val();
                var rData = {
                    Command: 'InsertUnit',
                    UnitName: L_comName,
                    WorkTypeId: L_gzhong,
                    UserName_c: $('#L_zdName').val(),
                    UserId_n: $('#L_zdName').attr('nid'),
                    LinkName: L_xiren,
                    Telephone: L_xirenPhone
                }

                if (L_comName == '') {
                    layer.msg('公司名称不能为空');
                    return false;
                }
                if (L_gzhong == '') {
                    layer.msg('工种不能为空');
                    return false;
                }
                if (L_zdName == '') {
                    layer.msg('请选择驻店员');
                    return false;
                }
                if (L_xiren == '') {
                    layer.msg('联系人不能为空');
                    return false;
                }
                if (L_xirenPhone == '') {
                    layer.msg('联系人电话不能为空');
                    return false;
                }
                reAjax(rData, function (res) {
                    if (res.code == 0) {
                        parent.layer.msg('新增成功');
                        if (IEVersion()) { //ie
                            parent.$('.x-nav .layui-icon').click();
                        }
                        parent.layui.table.reload("tableL");
                        parent.layer.close(parent._EditFrameIndex);
                    } else {
                        parent.layer.msg('新增失败');
                    }

                });
            });





        });

    </script>
</body>

</html>